package com.unisyou;

public class Demo4 {
    private static final boolean isChinese(char c) {
        Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
        if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
                || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
                || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
                || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
                || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        String str1 = "T恤;https://blog.csdn.net/vpqtxzmzezeqjj9977";//中文汉字
        String str2 = "；https://blog.csdn.net/vpqtxzmzezeqjj9977";//中文分号
        String str3 = "https://blog.csdn.net/vpqtxzmzezeqjj9977";//英文
        int flage = 0;
        for (char c : str1.toCharArray()) {
            if ((c >= 0x4E00 &&  c <= 0x9FA5) || isChinese(c)){
                flage = 1;
                System.out.println("发现中文字符："+c);
                break;    //有一个中文字符就返回
            }
        }
        if(flage!=1){
            System.out.println("恭喜，没有发现中文字符！");
        }
    }
}
